﻿using System;
using System.Net;
using System.Web.Mvc;
using Ext.Net;
using Ext.Net.MVC;
using Sharp.DataTransferObject;
using Sharp.Infrastructure;
using Sharp.Infrastructure.WebApiClient;
using Sharp.Portal.ExtNet;
using Sharp.Portal.Mvc;
using Sharp.ServiceContracts;
using Sharp.WebBooter.Areas.Platform.Models;
using PartialViewResult = Ext.Net.MVC.PartialViewResult;
// ReSharper disable Mvc.ViewNotResolved


namespace Sharp.WebBooter.Areas.Platform.Controllers
{
    /// <summary>
    /// 入口
    /// </summary>
    /// <param name="containerId">容器Id</param>
    /// <returns></returns>

    [Authorize]
    [AutomaticTemplate]
    public class NoticeController : SharpController
    {
        public ActionResult Index(string containerId)
        {
            return new PartialViewResult
            {
                Model = new NoticeIndexModel(),
                ContainerId = containerId,
                RenderMode = RenderMode.AddTo
            };
        }

        public ActionResult GetPaged(ExtRequestParameters parameters)
        {
            using (var proxy = new WebApiClientServiceProxy<IUserService>())
            {
                var pageInfo = proxy.Channel.GetNoticePaged(parameters.ToPagingFeature());

                return this.Store(pageInfo);
            }
        }
       
        [System.Web.Mvc.HttpPost]
        public ActionResult Delete(int[] ids)
        {
            Result res;
            using (var proxy = new WebApiClientServiceProxy<IUserService>())
            {
                res = proxy.Channel.DeleteNotices(ids);
            }

            return this.JsonNet(res);
        }
    }
}